# -*- coding:utf-8 -*-
# Author:Gao Xiang

# 发送数据到statsd服务端

import statsd


class Stats(object):

    def __init__(self, name):
        self.host = '10.171.215.115'
        self.port = 8125
        self.name = name

    def connect(self):
        statsd.Connection.set_defaults(host=self.host, port=self.port, sample_rate=1, disabled=False)
        self.gauge = statsd.Gauge(self.name)

    def send_data(self, hostname, value):
        self.gauge.send(hostname, value)
        # print(self.name)
        # print(self.value)